home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.awt;
-
- import java.awt.Canvas;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Event;
- import java.awt.Graphics;
-
- public class StateCheckBox extends Canvas {
- private static final int WIDTH = 14;
- private static final int HEIGHT = 14;
- public static final int TWO_STATE = 0;
- public static final int THREE_STATE = 1;
- public static final int STATE_UNCHECKED = 0;
- public static final int STATE_CHECKED = 1;
- public static final int STATE_DEFAULT = 2;
- private boolean enabled;
- private boolean pressed;
- private boolean released;
- private int width = 14;
- private int height = 14;
- private int state = 0;
- private int type = 0;
-
- public StateCheckBox() {
- this.state = 0;
- this.pressed = false;
- this.released = true;
- this.enabled = true;
- }
-
- public void setStyle(int var1) {
- this.type = var1;
- ((Component)this).invalidate();
- }
-
- public int getStyle() {
- return this.type;
- }
-
- public int getState() {
- return this.state;
- }
-
- public void setState(int var1) {
- if (this.state != var1) {
- this.state = var1;
- ((Component)this).invalidate();
- }
-
- }
-
- public boolean mouseDown(Event var1, int var2, int var3) {
- this.pressed = true;
- this.released = false;
- ((Component)this).repaint();
- return true;
- }
-
- public boolean mouseUp(Event var1, int var2, int var3) {
- if (this.pressed) {
- this.pressed = false;
- this.state = (this.state + 1) % (this.type == 0 ? 2 : 3);
- ((Component)this).repaint();
- ((Component)this).postEvent(new Event(this, 1001, (Object)null));
- }
-
- this.released = true;
- return true;
- }
-
- public boolean mouseEnter(Event var1, int var2, int var3) {
- if (!this.released) {
- this.mouseDown(var1, var2, var3);
- }
-
- return true;
- }
-
- public boolean mouseExit(Event var1, int var2, int var3) {
- if (this.pressed) {
- this.pressed = false;
- ((Component)this).repaint();
- }
-
- return true;
- }
-
- public void reshape(int var1, int var2, int var3, int var4) {
- this.width = 14;
- this.height = 14;
- super.reshape(var1, var2, var3, var4);
- }
-
- public Dimension preferredSize() {
- return new Dimension(this.width, this.height);
- }
-
- public synchronized void enable() {
- if (!this.enabled) {
- this.enabled = true;
- ((Component)this).repaint();
- }
-
- super.enable();
- }
-
- public synchronized void disable() {
- if (this.enabled) {
- this.enabled = false;
- ((Component)this).repaint();
- }
-
- super.disable();
- }
-
- public void paint(Graphics var1) {
- var1.clipRect(0, 0, this.width, this.height);
- var1.setColor(Color.white);
- var1.fillRect(0, 0, this.width, this.height);
- int var2 = this.width - 1;
- int var3 = this.height - 1;
- if (this.pressed) {
- var1.setColor(Color.lightGray);
- var1.fillRect(2, 2, var2 - 4, var3 - 4);
- }
-
- var1.setColor(Color.gray);
- var1.drawLine(0, var3 - 1, 0, 0);
- var1.drawLine(0, 0, var2 - 1, 0);
- var1.setColor(Color.lightGray);
- var1.drawLine(1, var3 - 2, var2 - 2, var3 - 2);
- var1.drawLine(var2 - 2, var3 - 2, var2 - 2, 1);
- var1.setColor(Color.black);
- var1.drawLine(1, var3 - 2, 1, 1);
- var1.drawLine(1, 1, var2 - 2, 1);
- switch (this.state) {
- case 2:
- var1.setColor(Color.lightGray);
- var1.fillRect(2, 2, var2 - 4, var3 - 4);
- var1.setColor(Color.black);
- case 1:
- for(int var4 = 0; var4 < 3; ++var4) {
- var1.drawLine(3, 5 + var4, 5, 7 + var4);
- var1.drawLine(5, 7 + var4, 9, 3 + var4);
- }
-
- return;
- default:
- }
- }
- }
-